<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>考勤数据</title>
    <?php include_once $_SERVER["DOCUMENT_ROOT"] . "/Public/include/resources.php"; ?>
</head>
<body>
<ul class="breadcrumb">
    <li><a href="/index.php/home/group/viewList">角色列表</a> <span class="divider">/</span></li>
    <li class="active">{$entity?'编辑' : '添加'}角色</li>
</ul>
<div class="demo-content">
    <div class="row">
        <div class="span24">
            <form id="J_Form" class="form-horizontal" method="post" action="/home/group/save">
                <input type="hidden" name="id" value="{$entity.id}"/>
                <h3>角色：</h3>
                <div class="control-group">
                    <label class="control-label"><s>*</s>名称：</label>
                    <div class="controls">
                        <input type="text" class="control-text" data-rules="{required:true}" name="title" value="{$entity.title}" />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">权限：</label>
                    <div class="controls">
                        <div id="s1">
                            <input type="hidden" name="rules" id="rules"/>
                        </div>
                    </div>
                </div>
                <div class="form-actions span5 offset3" style="position: absolute;bottom: 0;">
                    <div class="span13 offset3 ">
                        <button type="submit" class="button button-primary">保存</button>
                        <button type="reset" class="button">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    BUI.use('bui/form',function  (Form) {
        new Form.Form({
            srcNode : '#J_Form',
            submitType : 'ajax',
            callback : function(data){
                if (edy.ajaxHelp.handleAjax((data))) {
                    BUI.Message.Alert(data.message || "操作成功");
                    location.href = "/index.php/home/group/list";
                }
            }
        }).render();
        $.get("/index.php/home/group/getRules", function(data) {
            var items = data;
            var select = new BUI.Select.Select({
                render:'#s1',
                width: 500,
                valueField : '#rules',//显示tag的Combox必须存在valueField
                items:items,
                multipleSelect: true,
                forbitInput : true //只能从列表中选择，输入无效,一般用于suggest中
            });
            select.render();
            select.setSelectedValue("{$entity.rules}");
        });
    });
</script>
<!-- script end -->
</body>
</html>